import Counter from '../components/counter';
import { connect } from 'react-redux';
import { useDeps, composeAll } from 'mantra-core';

const mapStateToProps = (state) => ({
  counter: state.counters.counter
});

const mapDispatchToProps = (dispatch, {actions}) => ({
  onIncrement(value = 1) {
    dispatch(actions().counters.increase(value));
  },

  onReset: () => {
    dispatch(actions().counters.reset());
  },

  onRandom: () => {
    dispatch(actions().counters.random());
  }
});

export default composeAll(
  connect(mapStateToProps, mapDispatchToProps),
  useDeps()
)(Counter);
